package com.gitee.minimalismstyle.fresh.common.core.validate

import com.gitee.minimalismstyle.fresh.common.core.exception.MessageException

object ValueValidateFactory {
    val valueValidateMapping = mutableMapOf<String, ValueValidate>(
        "required" to RequiredValueValidate(),
        "int" to IntValueValidate(),
        "number" to NumberValueValidate(),
        "option" to OptionValueValidate(),
        "regex" to RegexValueValidate(),
        "length" to LengthValueValidate()
    )

    fun get(name: String): ValueValidate{
        return if(valueValidateMapping.containsKey(name)) {
            valueValidateMapping[name]!!
        }else{
            throw MessageException(message = "请定义${name}验证器")
        }
    }
}